<?php
/*
 * Creative Bulletin Board Generation 3
 * Version 1.0 Beta 1
 +------------------------------------
 * User Application Controller: Permission Keys
 * Started: September 24, 2009 5:54 PM (Week 1, Day 5)
 * Script version: 1.0
 */
class permissionkey{
	public function __construct($key){
		global $db, $main;
		$this->key = $main->secure_string($key);
		$query = $db->select("permission_keys", "*", "1", " WHERE `key` = '{$this->key}'");
		if($query){
			if($db->num_rows($query) == 0){
				$this->status = false;
			}
			else{
				$this->keyarray = $db->fetch_array($query);
				$this->status = true;
			}
		}
		else{
			$this->status = false;
		}
	}
	
	public function getStatus(){
		return $this->status;
	}
	
	public function getKey(){
		return $this->keyarray['key'];
	}
	
	public function getID(){
		return $this->keyarray['id'];
	}
	
	public function getDefaultValue(){
		return $this->keyarray['default_value'];
	}
	
	public function getDefaultGuestValue(){
		return $this->keyarray['guest_value'];
	}
	
	public function getName(){
		return $this->keyarray['name'];
	}
	
	public function getDesc(){
		return $this->keyarray['desc'];
	}
	
	public function delete(){
		global $db;
		$query = $db->query("DELETE FROM `".DB_PREFIX."permission_keys` WHERE `key` = '{$this->key}' LIMIT 1");
		return $query;
	}
}
